import React from "react";
import store from "../../store/store";
import { getMovieAction } from '../../store/actions/movieAction'


export default function Movie() {
    const { count } = store.getState().count
    //获取电影数据
    const { movieList } = store.getState().movie;

    //事件函数
    const getMovieHandle = () => {
        store.dispatch(getMovieAction())
    }

    return (
        <div>
            <h1>我是Movie组件</h1>
            <p>我收到的Count组件的值是 {count}</p>

            <button onClick={getMovieHandle}>获取电影的数据</button>
            <ul>
                {
                    movieList.map(item => {
                        return <li key={item.tvId}>{item.albumName}</li>
                    })
                }
            </ul>
        </div>
    )
}

//1.这里我们需要接收到Count组件的值,并随之而改变.

//点击按钮获取电影数据,先写事件函数,然后遍历电影数据